log: Support --key, as well as --branch and --unused
authorJoey Hess <joeyh@joeyh.name>
Fri, 3 Jan 2025 19:45:42 +0000 (15:45 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 3 Jan 2025 19:45:42 +0000 (15:45 -0400)
--all remains a special case, since it is more efficient and displays in a
nicer order.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
CHANGELOG
Command/Log.hs
doc/git-annex-log.mdwn
doc/todo/add_--key_to___34__annex_log__34__.mdwn

index d0c23b2b192cd2afda3a2a252d343dbf40b45103..e6a89262c3422352e2e3bd997cfb0e1368f98262 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ git-annex (10.20250103) UNRELEASED; urgency=medium
 
   * Improve handing of ssh connection problems during 
     remote annex.uuid discovery.
+  * log: Support --key, as well as --branch and --unused.
 
  -- Joey Hess <id@joeyh.name>  Fri, 03 Jan 2025 14:30:38 -0400
 
index 73ae37061c79e1cb344c216e72214aa41e47a71e..8dbbb77247377a30bd90bede0f6c5af66e85c6fe 100644 (file)
@@ -46,7 +46,7 @@ cmd = withAnnexOptions [jsonOptions, annexedMatchingOptions] $
 
 data LogOptions = LogOptions
        { logFiles :: CmdParams
-       , allOption :: Bool
+       , keyOptions :: Maybe KeyOptions
        , sizesOfOption :: Maybe (DeferredParse UUID)
        , sizesOption :: Bool
        , totalSizesOption :: Bool
@@ -62,11 +62,7 @@ data LogOptions = LogOptions
 optParser :: CmdParamsDesc -> Parser LogOptions
 optParser desc = LogOptions
        <$> cmdParams desc
-       <*> switch
-               ( long "all"
-               <> short 'A'
-               <> help "display location log changes to all files"
-               )
+       <*> optional parseKeyOptions
        <*> optional ((parseUUIDOption <$> strOption
                ( long "sizesof"
                <> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID)
@@ -138,22 +134,24 @@ seek o = ifM (null <$> Annex.Branch.getUnmergedRefs)
                zone <- liftIO getCurrentTimeZone
                outputter <- mkOutputter m zone o <$> jsonOutputEnabled
                let seeker = AnnexedFileSeeker
-                       { startAction = const $ start o outputter
+                       { startAction = const $ \si file key ->
+                               start o outputter (si, key, mkActionItem (file, key))
                        , checkContentPresent = Nothing
                        -- the way this uses the location log would not be
                        -- helped by precaching the current value
                        , usesLocationLog = False
                        }
-               case (logFiles o, allOption o) of
-                       (fs, False) -> withFilesInGitAnnex ww seeker
+               case (logFiles o, keyOptions o) of
+                       ([], Just WantAllKeys) -> 
+                               commandAction (startAll o outputter)
+                       (fs, ko) -> withKeyOptions ko False
+                               seeker (commandAction . start o outputter)
+                               (withFilesInGitAnnex ww seeker)
                                =<< workTreeItems ww fs
-                       ([], True) -> commandAction (startAll o outputter)
-                       (_, True) -> giveup "Cannot specify both files and --all"
 
-start :: LogOptions -> (ActionItem -> SeekInput -> Outputter) -> SeekInput -> RawFilePath -> Key -> CommandStart
-start o outputter si file key = do
+start :: LogOptions -> (ActionItem -> SeekInput -> Outputter) -> (SeekInput, Key, ActionItem) -> CommandStart
+start o outputter (si, key, ai) = do
        (changes, cleanup) <- getKeyLog key (passthruOptions o)
-       let ai = mkActionItem (file, key)
        showLogIncremental (outputter ai si) changes
        void $ liftIO cleanup
        stop
index 68f749b241299c86fe701f9097786aed31b54425..8432ce101102d57cc153c0bcf297dee200477372 100644 (file)
@@ -38,6 +38,18 @@ false, information may not have been committed to the branch yet.
   In this mode, the names of files are not available and keys are displayed
   instead.
 
+* `--key=keyname`
+
+  Displays the location log for the specified key.
+
+* `--branch=ref`
+
+  Displays the location log for the files in the specified branch or treeish.
+
+* `--unused`
+
+  Displays the location log for files found by last run of git-annex unused.
+
 * `--sizesof=repository`
 
   Displays a history of the total size of the annexed files in a repository
index fdeb6062b67b22847d0b8af36cb61e581242b3ac..a49bf3ef65a2e93f7a776ec72dfeeebc8a259384 100644 (file)
@@ -13,3 +13,5 @@ In my case -- doing archaeology on AFNI's test data in [https://github.com/afni/
 
 [[!meta author=yoh]]
 [[!tag projects/repronim]]
+
+> [[done]] --[[Joey]]